Skip to content

fix(dx-4439): Show human-readable prompts in interactive mode after command correction#2443

Open
harshithad0703 wants to merge 6 commits intodevelopmentfrom
fix/dx-4439-interactive-mode-messages
Open

fix(dx-4439): Show human-readable prompts in interactive mode after command correction#2443
harshithad0703 wants to merge 6 commits intodevelopmentfrom
fix/dx-4439-interactive-mode-messages

Conversation

@harshithad0703
Copy link
Contributor

@harshithad0703 harshithad0703 commented Mar 3, 2026

Problem

  1. Interactive prompts after command correction: When an invalid command is corrected (e.g. csdx loginasda → "Did you mean login?" → Yes), the CLI shows i18n keys (e.g. CLI_AUTH_LOGIN_ENTER_EMAIL_ADDRESS) instead of user-friendly text (e.g. "Enter your email address").

  2. Logout confirmation message: When the user answers No to "Are you sure you want to log out?", the CLI still shows "SUCCESS: You're already logged out", which is incorrect—the user chose not to log out and remains logged in.

Solution

1. Human-readable prompts after command correction

  • New prerun hook init-context-for-command: When context.messageFilePath is missing and the current command id is available (e.g. after correction), re-build CsdxContext for that command and re-initialize messageHandler, cliux, and SDK initiators so the correct plugin message file is loaded.
  • Hook is registered as the first prerun hook.

2. Correct message when user cancels logout

  • Added message key CLI_AUTH_LOGOUT_CANCELLED: "Log out cancelled".
  • In auth:logout, when the user answers No to the confirmation and is still authenticated, show "Log out cancelled" instead of "You're already logged out". "You're already logged out" is now only shown when the user is actually not authenticated.

Testing

Interactive prompts (command correction):

  1. Run csdx loginasda (or node bin/run.js loginasda from packages/contentstack).
  2. At "Did you mean login?", answer Yes.
  3. Expected: Prompt shows "Enter your email address" (not the key).

Logout cancel:

  1. Run csdx auth:login and log in.
  2. Run csdx auth:logout, answer No to the confirmation.
  3. Expected: Message shows "Log out cancelled" (not "You're already logged out").
  4. Run csdx whoami to confirm you are still logged in.

When an invalid command is corrected (e.g. loginasda → login), init had run
with the invalid command so context.messageFilePath was never set. Interactive
prompts then showed i18n keys (e.g. CLI_AUTH_LOGIN_ENTER_EMAIL_ADDRESS) instead
of messages (e.g. Enter your email address).

- Add prerun hook init-context-for-command that re-builds context and
  re-initializes messageHandler/cliux/SDKs when messageFilePath is missing
  and the actual command id is available (e.g. auth:login).
- Register the hook as the first prerun hook so it runs before other prerun logic.

Made-with: Cursor
@harshithad0703 harshithad0703 requested a review from a team as a code owner March 3, 2026 11:47
aman19K
aman19K previously approved these changes Mar 4, 2026
@aman19K
Copy link
Contributor

aman19K commented Mar 4, 2026

@harshithad0703 , pls check with @shafeeqd959 regarding base branch.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 80 261 25 ❌ Failed
🟡 Medium Severity 29 279 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 261
  • Medium without fixes: 279
  • Low without fixes: 0

❌ BUILD FAILED - Security checks failed

Please review and fix the security vulnerabilities before merging.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 80 261 100 ✅ Passed
🟡 Medium Severity 29 279 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 261
  • Medium without fixes: 279
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants